package com.capacity.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.capacity.domain.CscIndustryInfo;
import com.capacity.service.ICscIndustryInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 产品品类Controller
 * 
 * @author fz
 * @date 2024-02-01
 */
@RestController
@RequestMapping("/capacity/industry")
public class CscIndustryInfoController extends BaseController
{
    @Autowired
    private ICscIndustryInfoService cscIndustryInfoService;

    /**
     * 查询产品品类列表
     */
    @PreAuthorize("@ss.hasPermi('capacity:industry:list')")
    @GetMapping("/list")
    public AjaxResult list(CscIndustryInfo cscIndustryInfo)
    {
        List<CscIndustryInfo> list = cscIndustryInfoService.selectCscIndustryInfoList(cscIndustryInfo);
        return success(list);
    }

    /**
     * 导出产品品类列表
     */
    @PreAuthorize("@ss.hasPermi('capacity:industry:export')")
    @Log(title = "产品品类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CscIndustryInfo cscIndustryInfo)
    {
        List<CscIndustryInfo> list = cscIndustryInfoService.selectCscIndustryInfoList(cscIndustryInfo);
        ExcelUtil<CscIndustryInfo> util = new ExcelUtil<CscIndustryInfo>(CscIndustryInfo.class);
        util.exportExcel(response, list, "产品品类数据");
    }

    /**
     * 获取产品品类详细信息
     */
    @PreAuthorize("@ss.hasPermi('capacity:industry:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cscIndustryInfoService.selectCscIndustryInfoById(id));
    }

    /**
     * 新增产品品类
     */
    @PreAuthorize("@ss.hasPermi('capacity:industry:add')")
    @Log(title = "产品品类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CscIndustryInfo cscIndustryInfo)
    {
        return toAjax(cscIndustryInfoService.insertCscIndustryInfo(cscIndustryInfo));
    }

    /**
     * 修改产品品类
     */
    @PreAuthorize("@ss.hasPermi('capacity:industry:edit')")
    @Log(title = "产品品类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CscIndustryInfo cscIndustryInfo)
    {
        return toAjax(cscIndustryInfoService.updateCscIndustryInfo(cscIndustryInfo));
    }

    /**
     * 删除产品品类
     */
    @PreAuthorize("@ss.hasPermi('capacity:industry:remove')")
    @Log(title = "产品品类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cscIndustryInfoService.deleteCscIndustryInfoByIds(ids));
    }
}
